//
//  MedInfoViewController.m
//  idoctor
//
//  Created by Mr Lee on 2017/6/1.
//  Copyright © 2017年 Mr Lee. All rights reserved.
//



#define medInfo @"http://www.tngou.net/api/drug/show?"

#import "MedInfoViewController.h"
#import <WebKit/WebKit.h>

@interface MedInfoViewController ()
{

    NSMutableDictionary *_medDict;

}
@property(nonatomic,strong)UIImageView *medImgV;
@property(nonatomic,strong)WKWebView *medWebView;

@end

@implementation MedInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initUI];
    [self loadInfo];
    
}
-(void)initUI
{
    
    self.navigationItem.title = @"药品详情";
    self.navigationController.navigationBar.translucent = NO;
    
    _medImgV = [[UIImageView alloc]init];
    
    _medImgV.frame = CGRectMake(0, 0, 106, 106);
    
    _medImgV.center = CGPointMake(self.view.frame.size.width/2, 60);
    
    _medImgV.backgroundColor = [UIColor orangeColor];
    
    [_medImgV sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://tnfs.tngou.net/image%@",_medImgStr]] placeholderImage:[UIImage imageNamed:@"1.jpeg"]];

    
    [self.view addSubview:_medImgV];
    
    _medWebView = [[WKWebView alloc]init];
    
    _medWebView.frame = CGRectMake(0, CGRectGetMaxY(_medImgV.frame)+5, self.view.frame.size.width, self.view.frame.size.height-CGRectGetMaxY(_medImgV.frame)-5-49-64);
    
    [self.view addSubview:_medWebView];
    
}

-(void)loadInfo
{
    
    _medDict = [NSMutableDictionary dictionary];
    
    [_medDict setObject:_medId forKey:@"id"];
    
    [SVProgressHUD showWithStatus:@"加载中"];
    
    [[HttpRequest shardWebUtil]getNetworkRequestURLString:medInfo parameters:_medDict success:^(id obj)
     {
         
         [SVProgressHUD dismiss];
         
         
         NSString *htmlStr = obj[@"message"];
         
         [_medWebView loadHTMLString:htmlStr baseURL:nil];
         
     } fail:^(NSError *error) {
         
     }];
    
}

-(void)viewWillDisappear:(BOOL)animated
{
    
    [SVProgressHUD dismiss];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
